// Decompiled by Jad v1.5.8e. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/kpdus/jad.html
// Decompiler options: packimports(3) 
// Source File Name:   StatusTarefaDAO.java

package gerenciadorprojetos.dao.hibernate;

import gerenciadorprojetos.dao.StatusTarefa;
import java.util.List;
import org.apache.log4j.Logger;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class StatusTarefaDAO extends HibernateDaoSupport
{
    private Logger logger = Logger.getLogger(StatusTarefaDAO.class);

    public StatusTarefaDAO()
    {
        logger = Logger.getLogger(StatusTarefaDAO.class);
    }

    public List obterStatus()
    {
        List l = getHibernateTemplate().find("FROM StatusTarefa ORDER BY descStatusTarefa");
        getHibernateTemplate().initialize(l);
        return l;
    }

    public StatusTarefa obterStatusPorID(int id)
    {
        return (StatusTarefa)getHibernateTemplate().get(StatusTarefa.class, Integer.valueOf(id));
    }

    public StatusTarefa obterStatusPorDescricao(String desc)
    {
        List l = getHibernateTemplate().find("FROM StatusTarefa WHERE descStatusTarefa = ?", desc);
        if(l.size() > 1)
        {
            logger.debug((new StringBuilder()).append("Nao existe uma status com esta descricao. Descricao: ").append(desc).toString());
            throw new RuntimeException((new StringBuilder()).append("Nao existe uma status com esta descricaoo. Descricao: ").append(desc).toString());
        } else
        {
            return (StatusTarefa)l.get(0);
        }
    }
}
